﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;


namespace ExceptionReader
{
	public partial class FormMain : Form
	{
		public FormMain()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			textBox2.Text = Path.GetDirectoryName(Application.ExecutablePath);
			textBox2.Select();
			/*
			Hashtable l_oItem;
			Exception l_oException;

			// Open the file containing the data that you want to deserialize.
			FileStream l_oFileStream = new FileStream("Dump.Exception", FileMode.Open);

			BinaryFormatter b = new BinaryFormatter();
			l_oItem = (Hashtable)b.Deserialize(l_oFileStream);

			l_oItem = new Hashtable();
			l_oException = new Exception((String)l_oItem["Message"]);
			//l_oException.StackTrace = (String)l_oItem["Trace"];
			//l_oException.Data = (IDictionary)l_oItem["Data"];

			l_oFileStream.Close();*/
		}

		private void button1_Click(object sender, EventArgs e)
		{
			OpenFileDialog l_oDialog = new OpenFileDialog();
			Exception l_oException;
			FileStream fs;

			l_oDialog.InitialDirectory = textBox2.Text;

			if (l_oDialog.ShowDialog() == DialogResult.OK)
			{
				fs = File.Open(l_oDialog.FileName, FileMode.Open);
				BinaryFormatter b = new BinaryFormatter();
				l_oException = (Exception)b.Deserialize(fs);
				fs.Close();

				textBox1.Text = l_oException.ToString();
			}
		}
	}
}
